package com.dailyblue.java.cloud.prodvier.controller;

import com.dailyblue.java.commons.util.ResultTool;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dailyblue.java.commons.util.JsonResult;

@RestController
@RequestMapping("/provider")
public class ProviderController {
    // application.yml中获取到server.port的值并赋予port变量
    @Value("${server.port}")
    private Integer port;

    @GetMapping("/a")
    public JsonResult a() {
        return ResultTool.success("This is a method!");
    }

    @GetMapping("/b/{a}")
    public JsonResult b(@PathVariable("a") int a) {
        return ResultTool.success("This is b method!a:" + a + "，port:" + port);
    }

    @GetMapping("/c/{a}/{b}")
    public JsonResult c(@PathVariable("a") int a, @PathVariable("b") String b) {
        return ResultTool.success("This is c method!a:" + a + ",b:" + b + "，port:" + port);
    }
}
